package team.star.werespos.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

/**
 * OrderMaster class<br/>
 * 订单
 * @author hdonghong
 * @since 2019/05/04
 */
@TableName("`order_master`")
@Data
@Accessors(chain = true)
public class OrderMaster implements Serializable {

    private static final long serialVersionUID = 5610619185893983267L;

    @TableId
    private Integer orderId;

    /** 订单总金额 */
    private BigDecimal orderAmount;

    /** 订单状态：0新下单；1已付款；-1已取消 */
    private Integer orderStatus;

    /** 桌号 */
    private Integer tableNum;

    @JsonIgnore
    @TableLogic
    private Integer isDel;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Instant createTime;

    @JsonIgnore
    private Instant updateTime;

    @TableField(exist = false)
    List<OrderDetail> orderDetailList;

    public OrderMaster() {
        orderDetailList = new ArrayList<>();
        orderAmount = BigDecimal.ZERO;
    }

}
